package mya_dc.compilation_server.gui;

import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import mya_dc.compilation_server.database.DatabaseManager;

public class DatabasePropertiesWindow extends JDialog
{
	private static final long serialVersionUID = 200449904929888561L;
	private JTextField administratorField;
	private JTextField urlField;
	private JTextField driverField;
	private JTextField directoryField;
	private JTextField nameField;
	public DatabasePropertiesWindow() {
		super();
		getContentPane().setLayout(null);
		setModalityType(ModalityType.DOCUMENT_MODAL);
		setModal(true);
		setResizable(false);
		setTitle("Database Properties");
		setBounds(200, 200, 567, 307);

		final JPanel panel = new JPanel();
		panel.setLayout(null);
		panel.setBorder(new TitledBorder(null, "Database Information", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, SystemColor.textHighlight));
		panel.setBounds(10, 10, 541, 216);
		getContentPane().add(panel);

		final JLabel administratorUserNameLabel = new JLabel();
		administratorUserNameLabel.setBounds(30, 67, 88, 30);
		panel.add(administratorUserNameLabel);
		administratorUserNameLabel.setFont(new Font("", Font.PLAIN, 14));
		administratorUserNameLabel.setText("Administrator:");

		administratorField = new JTextField();
		administratorField.setBounds(124, 68, 197, 30);
		administratorField.setText("sa");
		panel.add(administratorField);
		administratorField.setEditable(false);

		final JLabel databaseNameLabel = new JLabel();
		databaseNameLabel.setBounds(30, 31, 120, 30);
		panel.add(databaseNameLabel);
		databaseNameLabel.setFont(new Font("", Font.PLAIN, 14));
		databaseNameLabel.setText("Name:");

		nameField = new JTextField();
		nameField.setBounds(124, 32, 197, 30);
		panel.add(nameField);
		nameField.setText("MYADatabase");
		nameField.setEditable(false);

		final JLabel directoryLabel = new JLabel();
		directoryLabel.setBounds(30, 172, 88, 30);
		panel.add(directoryLabel);
		directoryLabel.setFont(new Font("", Font.PLAIN, 14));
		directoryLabel.setText("Directory:");

		directoryField = new JTextField();
		directoryField.setBounds(124, 173, 394, 30);
		directoryField.setText(DatabaseManager.getDatabaseSettings()[0]);
		panel.add(directoryField);
		directoryField.setEditable(false);

		final JLabel driverLabel = new JLabel();
		driverLabel.setBounds(30, 103, 120, 30);
		panel.add(driverLabel);
		driverLabel.setFont(new Font("", Font.PLAIN, 14));
		driverLabel.setText("Driver:");

		urlField = new JTextField();
		urlField.setBounds(124, 136, 394, 30);
		urlField.setText(DatabaseManager.getDatabaseSettings()[1]);
		panel.add(urlField);
		urlField.setEditable(false);

		final JLabel urlLabel = new JLabel();
		urlLabel.setBounds(30, 140, 32, 30);
		panel.add(urlLabel);
		urlLabel.setFont(new Font("", Font.PLAIN, 14));
		urlLabel.setText("URL:");

		driverField = new JTextField();
		driverField.setBounds(124, 103, 197, 30);
		driverField.setText("org.h2.Driver");
		panel.add(driverField);
		driverField.setEditable(false);

		final JButton okButton = new JButton();
		okButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				setVisible(false);
			}
		});
		okButton.setText("OK");
		okButton.setBounds(218, 232, 107, 24);
		getContentPane().add(okButton);
		
		setVisible(true);
	}

}
